set more off
clear all
set more off
grstyle init
grstyle set plain
* colorpalette #259797 #db4437
graph set window fontface "Times New Roman"

log using CivicPulseStataResults.log, replace

cd "C:\Users\mhoro\Dropbox\CCES 2020\Civic Pulse\"

use civic_pulse_processed_for_stata.dta, clear

* gen autoindustry=0
* replace autoindustry=1 if (state_abb=="MI" | state_abb=="MS" |state_abb=="AL" | state_abb=="KY" | state_abb=="MO" | state_abb=="TN" | state_abb=="IL" | state_abb=="TX" | state_abb=="IN" | state_abb=="OH")
* replace autoindustry=. if state_abb=="."
* label var autoindustry "Top 10 auto manufacturing state (0/1)"

* gen aiinfo=aihomework2+aimusicmovies
* label var aiinfo "Self-Reported AI Use"

eststo m1: regress carsupport sex age white_non_hispanic education2 pid3 autoindustry aiinfo general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

eststo m2: regress hcsupport sex age white_non_hispanic education2 pid3 hcindustry2 aiinfo general1 general2 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

coefplot (m1, mcolor("59 154 178") lcolor("59 154 178") ciopts(lcolor("59 154 178") lwidth(.6))) (m2, mcolor("242 26 0") lcolor("242 26 0") ciopts(lcolor("242 26 0") lwidth(.6))), xline(0, lcolor(black)) drop(_cons urban_prop2 college_prop2 unemployment2) levels(95) coeflabels(, wrap(40)) xlabel(, grid labsize(medsmall)) xtitle(" " "Effect Size", size(medsmall)) ylabel(, grid labsize(medsmall)) legend(lab(2 "Vehicles") lab(4 "Surgery") region(lwidth(none))) order(sex age white_non_hispanic education2 pid3 autoindustry hcindustry2 aiinfo general1 general2 vehicles1)

graph save "Graph" "CarsAndSurgery.gph", replace
graph export "CarsAndSurgery.png", as(png) name("Graph") replace

esttab m1 m2 using Table1.tex, replace f t(3) scalars("ll Log Likelihood" F "chi2 Chi Squared") legend label collabels(none) varlabels(_cons Constant) se(3) pr2 r2 b(3) star(* 0.10 ** 0.05 *** 0.01) nobaselevels order(sex age white_non_hispanic education2 pid3 autoindustry hcindustry2 vehicles1 aiinfo general1 general2 urban_prop2 college_prop2 unemployment2) mtitles("\shortstack{Self-Driving Cars\\OLS\\b/SE}" "\shortstack{Autonomous Surgery\\OLS\\b/SE}") eqlabel(none)

regress carsupport vehicles1 sex age white_non_hispanic education2 pid3 autoindustry aiinfo general1 general2 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

coefplot, xline(0, lcolor("242 26 0")) drop(_cons urban_prop2 college_prop2 unemployment2) levels(95) mfcolor("59 154 178") lcolor("59 154 178") mlcolor("59 154 178") mcolor("59 154 178") ciopts(lcolor("59 154 178" "59 154 178") lwidth(.6)) coeflabels(, wrap(35)) title("Autonomous Vehicles" " ", size(medium)) xlabel(, grid labsize(medsmall)) xtitle(" " "Effect Size", size(medsmall)) ylabel(, grid labsize(medsmall))

graph save "Graph" "Cars.gph", replace
graph export "Cars.png", as(png) name("Graph") replace

regress hcsupport sex age white_non_hispanic education2 pid3 aiinfo hcindustry2 general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

coefplot, xline(0, lcolor("242 26 0")) drop(_cons urban_prop2 college_prop2 unemployment2) levels(95) mfcolor("59 154 178") lcolor("59 154 178") mlcolor("59 154 178") mcolor("59 154 178") ciopts(lcolor("59 154 178" "59 154 178") lwidth(.6)) coeflabels(, wrap(35)) title("Surgery" " ", size(medium)) xlabel(, grid labsize(medsmall)) xtitle(" " "Effect Size", size(medsmall)) ylabel(, grid labsize(medsmall))

graph save "Graph" "Surgery.gph", replace
graph export "Surgery.png", as(png) name("Graph") replace

estimates clear

eststo m1: regress aigrid_1 sex age white_non_hispanic education2 pid3 aiinfo general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

eststo m2: regress aigrid_2 sex age white_non_hispanic education2 pid3 aiinfo general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

eststo m3: regress aigrid_3 sex age white_non_hispanic education2 pid3 aiinfo general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

eststo m4: regress aigrid_4 sex age white_non_hispanic education2 pid3 aiinfo general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

eststo m5: regress aigrid_5 sex age white_non_hispanic education2 pid3 aiinfo general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

eststo m6: regress aigrid_6 sex age white_non_hispanic education2 pid3 aiinfo general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

eststo m7: regress aigrid_7 sex age white_non_hispanic education2 pid3 aiinfo general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

eststo m8: regress aigrid_8 sex age white_non_hispanic education2 pid3 aiinfo general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

eststo m9: regress aigrid_9 sex age white_non_hispanic education2 pid3 aiinfo general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 [iweight=weight_1], cluster(state_code)

esttab m1 m2 m3 m4 m5 m6 m7 m8 m9 using Table2.tex, replace f t(3) scalars("ll Log Likelihood" F "chi2 Chi Squared") legend label collabels(none) varlabels(_cons Constant) se(3) pr2 r2 b(3) star(* 0.10 ** 0.05 *** 0.01) nobaselevels order(sex age white_non_hispanic education2 pid3 vehicles1 aiinfo general1 general2 urban_prop2 college_prop2 unemployment2) mtitles("\shortstack{Facial Recognition\\Software\\OLS\\b/SE}" "\shortstack{General\\Monitoring\\OLS\\b/SE}" "\shortstack{State\\Jobs\\OLS\\b/SE}" "\shortstack{Prison\\Sentences\\OLS\\b/SE}" "\shortstack{Transplant\\List\\OLS\\b/SE}" "\shortstack{Natural Disaster\\Impact Planning\\OLS\\b/SE}" "\shortstack{Responding To\\911 Calls\\OLS\\b/SE}" "\shortstack{Military\\Surveillance\\OLS\\b/SE}" "\shortstack{Use of\\Military Force\\OLS\\b/SE}")

esttab m1 m2 m3 m4 m5 m6 m7 m8 m9 using Table2.rtf, replace t(3) scalars("ll Log Likelihood" F "chi2 Chi Squared") legend label collabels(none) varlabels(_cons Constant) se(3) pr2 r2 b(3) star(* 0.10 ** 0.05 *** 0.01) nobaselevels order(sex age white_non_hispanic education2 pid3 vehicles1 aiinfo general1 general2 urban_prop2 college_prop2 unemployment2) mtitles("\shortstack{Facial Recognition\\Software\\OLS\\b/SE}" "\shortstack{General Monitoring\\OLS\\b/SE}" "\shortstack{State Jobs\\OLS\\b/SE}" "\shortstack{Prison Sentences\\OLS\\b/SE}" "\shortstack{Transplant List\\OLS\\b/SE}" "\shortstack{Natural Disaster\\Impact Planning\\OLS\\b/SE}" "\shortstack{Responding To\\911 Calls\\OLS\\b/SE}" "\shortstack{Military\\Surveillance\\OLS\\b/SE}" "\shortstack{Use of\\Military Force\\OLS\\b/SE}")

estimates clear

eststo m1: regress carsupport sex age white_non_hispanic education2 pid3 autoindustry aiinfo general1 general2 vehicles1 urban_prop2 college_prop2 unemployment2 if ai_grid_complete==1 [iweight=weight_1], cluster(state_code)

eststo m2: regress hcsupport sex age white_non_hispanic education2 pid3 hcindustry2 aiinfo general1 general2 urban_prop2 college_prop2 unemployment2 if ai_grid_complete==1 [iweight=weight_1], cluster(state_code)

coefplot (m1, mcolor("59 154 178") lcolor("59 154 178") ciopts(lcolor("59 154 178") lwidth(.6))) (m2, mcolor("242 26 0") lcolor("242 26 0") ciopts(lcolor("242 26 0") lwidth(.6))), xline(0, lcolor(black)) drop(_cons urban_prop2 college_prop2 unemployment2) levels(95) coeflabels(, wrap(40)) xlabel(, grid labsize(medsmall)) xtitle(" " "Marginal Effect", size(medsmall)) ylabel(, grid labsize(medsmall)) legend(lab(2 "Cars") lab(4 "Surgery") region(lwidth(none))) order(sex age white_non_hispanic education2 pid3 autoindustry hcindustry2 aiinfo general1 general2 vehicles1)

graph save "Graph" "CarsAndSurgeryAppendix.gph", replace
graph export "CarsAndSurgeryAppendix.png", as(png) name("Graph") replace

esttab m1 m2 using TableLimitedRespondents.tex, replace f t(3) scalars("ll Log Likelihood" F "chi2 Chi Squared") legend label collabels(none) varlabels(_cons Constant) se(3) pr2 r2 b(3) star(* 0.10 ** 0.05 *** 0.01) nobaselevels order(sex age white_non_hispanic education2 pid3 autoindustry hcindustry2 vehicles1 aiinfo general1 general2 urban_prop2 college_prop2 unemployment2) mtitles("\shortstack{Self-Driving Cars\\OLS\\b/SE}" "\shortstack{Autonomous Surgery\\OLS\\b/SE}") eqlabel(none)

log close